import request, { type ListQuery, type ListResponse } from "@/utils/request";

const BANNER_BASE_URL = "/api";

const BannerAPI = {
  getBannerList: (params: BannerListParams) => {
    return request.get<any, ListResponse<BannerType>>(`${BANNER_BASE_URL}/internal/banner/`, {
      params,
    });
  },
  addBanner: (data: any) => {
    return request.post(`${BANNER_BASE_URL}/internal/banner/`, data, {
      headers: {
        "Content-Type": "multipart/form-data",
      },
    });
  },
  updateBanner: (data: Partial<BannerType>) => {
    return request.put(`${BANNER_BASE_URL}/internal/banner/${data.id}/`, data);
  },
  deleteBanner: (id: number) => {
    return request.delete(`${BANNER_BASE_URL}/internal/banner/${id}/`);
  },
};

export type BannerListParams = {} & ListQuery;

export type BannerType = {
  id: number;
  created_at: string;
  updated_at: string;
  is_active: boolean;
  name: string;
  image_url: string;
  skip_path: string;
};

export default BannerAPI;
